package o;

import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class zg {
    private final List<String> ˊ = new ArrayList();
    private final Map<String, List<c<?, ?>>> ॱ = new HashMap();

    static class c<T, R> {
        final se<T, R> ˋ;
        private final Class<T> ˎ;
        final Class<R> ॱ;

        public c(@NonNull Class<T> cls, @NonNull Class<R> cls2, se<T, R> seVar) {
            this.ˎ = cls;
            this.ॱ = cls2;
            this.ˋ = seVar;
        }

        public boolean ॱ(@NonNull Class<?> cls, @NonNull Class<?> cls2) {
            return this.ˎ.isAssignableFrom(cls) && cls2.isAssignableFrom(this.ॱ);
        }
    }

    public synchronized void ˎ(@NonNull List<String> list) {
        List<String> arrayList = new ArrayList(this.ˊ);
        this.ˊ.clear();
        this.ˊ.addAll(list);
        for (String str : arrayList) {
            if (!list.contains(str)) {
                this.ˊ.add(str);
            }
        }
    }

    @NonNull
    public synchronized <T, R> List<se<T, R>> ॱ(@NonNull Class<T> cls, @NonNull Class<R> cls2) {
        List<se<T, R>> arrayList;
        arrayList = new ArrayList();
        for (String str : this.ˊ) {
            List<c> list = (List) this.ॱ.get(str);
            if (list != null) {
                for (c cVar : list) {
                    if (cVar.ॱ(cls, cls2)) {
                        arrayList.add(cVar.ˋ);
                    }
                }
            }
        }
        return arrayList;
    }

    @NonNull
    public synchronized <T, R> List<Class<R>> ˎ(@NonNull Class<T> cls, @NonNull Class<R> cls2) {
        List<Class<R>> arrayList;
        arrayList = new ArrayList();
        for (String str : this.ˊ) {
            List<c> list = (List) this.ॱ.get(str);
            if (list != null) {
                for (c cVar : list) {
                    if (cVar.ॱ(cls, cls2) && !arrayList.contains(cVar.ॱ)) {
                        arrayList.add(cVar.ॱ);
                    }
                }
            }
        }
        return arrayList;
    }

    public synchronized <T, R> void ˏ(@NonNull String str, @NonNull se<T, R> seVar, @NonNull Class<T> cls, @NonNull Class<R> cls2) {
        ˏ(str).add(new c(cls, cls2, seVar));
    }

    @NonNull
    private synchronized List<c<?, ?>> ˏ(@NonNull String str) {
        List<c<?, ?>> list;
        if (!this.ˊ.contains(str)) {
            this.ˊ.add(str);
        }
        list = (List) this.ॱ.get(str);
        if (list == null) {
            list = new ArrayList();
            this.ॱ.put(str, list);
        }
        return list;
    }
}
